<?php

namespace app\api\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
            'user_id'=>'require|number',
            'user_name'=>['require'],
            'user_pwd'=>'require',
            'code'=>'require|number|length:6',
            'user_icon'=>'require|image|fileSize:2000000|fileExt:jpg,png,bmp,jpeg',
            'user_phone'=>'require|mobile',
            'user_email'=>'require|email',
            'user_nickname'=>'require|chsDash'
        ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'username.require' => '名称必须',
        'code.require' => '验证码不能为空',
        'code.number' => '验证码只能是数字',
        'code.length' => '验证码长度为6位数字',
    ];
    
    /**
     * 定义验证场景
     */
    protected $scene = [
        'index'  =>  [''],
        'login'  =>  ['user_name','user_pwd'],
        'register'  =>  ['user_name','user_pwd','code'],
        'upload_head_img'  =>  ['user_id','user_icon'],
        'change_pwd'=>['user_name','user_pwd'],
        'find_pwd'=>['user_name','user_pwd','code'],
        'bind_phone'=>['user_id','user_phone','code'],
        'bind_email'=>['user_id','user_email','code'],
        'bind_user_name'=>['user_id','user_name','code'],
        'set_nickname'=>['user_id','user_nickname'],
    ];
}
